<template>
  <div v-dialogDrag>
    <el-dialog
      title="修改密码"
      v-model="dialogVisible"
      width="30%"
      :close-on-click-modal="false"
      :before-close="handleClose"
    >
      <el-form label-position="right" label-width="80px" :model="userEdit">
        <el-form-item label="用户名">
          <el-input disabled v-model="userEdit.name"></el-input>
        </el-form-item>
        <el-form-item label="新密码">
          <el-input v-model="userEdit.password"></el-input>
        </el-form-item>
        <el-form-item label="确认密码">
          <el-input v-model="userEdit.twoPassword"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" @click="handleOk">确 定</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, reactive, PropType } from 'vue'
interface User {
  orgName: string
}
export default defineComponent({
  name: 'EditPassword',
  emits: ['handleClose'],
  props: {
    user: {
      type: Object as PropType<User>,
      required: true
    }
  },
  setup(props, context) {
    const dialogVisible = ref(true)
    const handleClose = () => {
      context.emit('handleClose')
    }
    const handleOk = () => {
      context.emit('handleClose')
    }

    // 用户填写修改信息
    const userEdit = reactive({
      name: props.user.orgName,
      password: '',
      twoPassword: ''
    })
    return {
      dialogVisible,
      userEdit,
      handleOk,
      handleClose
    }
  }
})
</script>

<style scoped></style>
